/**
 * 判断服务请求是否成功
 * @param response
 * @returns {*|boolean}
 */
export function isResponseSuccess (response) {
  return response && response.status && response.status == 0;
}

/**
 * 获取当前表格行的实际序号
 * @param {* 当前页序号} index Number
 * @param {* 分页数据} pagination Object
 * @returns 总量序号
 */
export const getCurrentTableIndex = (index, pagination) => {
  const { current, size } = pagination;
  return (current - 1) * size + index + 1;
}

/**
 * 获取含有序号的表格数据
 * @param {* 表格数据} list Array
 * @param {* 分页数据} pagination Object
 * @param {* 序号key} indexKey String
 * @returns 表格数据
 */
export const getHasIndexTableData = (list, pagination, indexKey = 'index') => {
  list = list || [];
  return list.map((item, index) => ({ ...item, [indexKey]: getCurrentTableIndex(index, pagination) }));
}
